<?php
require_once 'includes/config.php';
require_once 'includes/functions.php';
require_once 'includes/class.phpmailer.php';

//form submit action
if(isset($_POST['submit']) && $_POST['submit']=="REGISTER")
{
	$businessName		    =	$_REQUEST['businessName'];
	$physicalLocation	    =	$_REQUEST['physicalLocation'];
	$btype			        =	$_REQUEST['btype'];
	$businessDescription	=	$_REQUEST['businessDescription'];
	$other_business_type    =   addslashes($_REQUEST['other_business_type']);
	$address1		        =	$_REQUEST['address1'];
	$city					=	$_REQUEST['city'];
	$state					=	$_REQUEST['state'];
	$country				=	$_REQUEST['country'];
	$zip					=	$_REQUEST['zip'];
	$phoneNo1				=	$_REQUEST['phoneNumber1']."-".$_REQUEST['phoneNumber2']."-".$_REQUEST['phoneNumber3'];
	if(!empty($_REQUEST['extension1']))
		$phoneNo1		   .= 	"-".$_REQUEST['extension1'];
	$email					=	$_REQUEST['email'];	
	$firstName				=	$_REQUEST['firstName'];
	$lastName				=	$_REQUEST['lastName'];
	$phoneNo2				=	$_REQUEST['phoneNumber4']."-".$_REQUEST['phoneNumber5']."-".$_REQUEST['phoneNumber6'];
	if(!empty($_REQUEST['extension2']))
		$phoneNo2		   .=   "-".$_REQUEST['extension2'];
	$businessEmail			=	$_REQUEST['businessEmail'];
	$driverLicence			=	$_REQUEST['driverLicence'];
	$userName				=	$_REQUEST['userName'];
	$password				=	$_REQUEST['password'];
	$secretQuestion			=	$_REQUEST['secretQuestion'];
	$secretAnswer			=	$_REQUEST['secretAnswer'];
	$dob					=	$_REQUEST['dYear']."-".$_REQUEST['dMonth']."-".$_REQUEST['dDay'];
	$currentDate			=	date("Y-m-d");
	
	if(is_numeric($state)) {
		$state 		= 	getStateName($state);
	} 
	if(is_numeric($city)) {
		$city 		= 	getCityName($city);
	}
	
	

	//$phoneNumber=$_REQUEST['phonenumber'];
	$sqlSelUsr = "select * from tbl_users where username='".$userName."'";
	$rstSelUsr = mysql_query($sqlSelUsr) or die(mysql_error());
	$noSelUsr = @mysql_num_rows($rstSelUsr);
	if($noSelUsr==0)
	{
			  $confirmCode=get_rand_id(5);
			
              $matchCriteria='';
			  $sameDOB=mysql_num_rows(mysql_query("SELECT * FROM tbl_users WHERE dob='".$dob."' AND user_type=3 AND (denyStatus=1 OR status=4)"));
			  if($sameDOB>0)
			  {
				 $matchCriteria.='Date of Birth, ';
			  }
			  
			  $sameEmail=mysql_num_rows(mysql_query("SELECT * FROM tbl_users WHERE email='".$email."' AND user_type=3 AND (denyStatus=1 OR status=4)"));
			  if($sameEmail>0)
			  {
				 $matchCriteria.='Email, ';
			  }
			  
			  $sameFname=mysql_num_rows(mysql_query("SELECT * FROM tbl_users WHERE (first_name='%".$firstName."%' OR first_name='".$firstName."') AND user_type=3 AND (denyStatus=1 OR status=4)"));
			  if($sameFname>0)
			  {
				 $matchCriteria.='First Name, ';
			  }
			  
			  $sameLname=mysql_num_rows(mysql_query("SELECT * FROM tbl_users WHERE (last_name='%".$lastName."%' OR last_name='".$lastName."') AND user_type=3 AND (denyStatus=1 OR status=4)"));
			  if($sameFname>0)
			  {
				 $matchCriteria.='Last Name, ';
			  }

			  $sameFirstLastName=mysql_num_rows(mysql_query("SELECT * FROM tbl_users WHERE (first_name='%".$firstName."%' OR first_name='".$firstName."') AND (last_name='%".$lastName."%' OR last_name='".$lastName."') AND user_type=3 AND (denyStatus=1 OR status=4)"));
			  if($sameFirstLastName>0)
			  {
				 $matchCriteria.='First Name and Last Name, ';
			  }
			  
			  $sameBusinessName=mysql_num_rows(mysql_query("SELECT * FROM tbl_users WHERE (business_name='%".$businessName."%' OR business_name='".$businessName."') AND user_type=3 AND (denyStatus=1 OR status=4)"));
			  if($sameBusinessName>0)
			  {
				 $matchCriteria.='Business Name, ';
			  }
			  
			  $sameBusinessAddress=mysql_num_rows(mysql_query("SELECT * FROM tbl_users WHERE (address_line_1='%".$address1."%' OR address_line_1='".$address1."') AND user_type=3 AND (denyStatus=1 OR status=4)"));
			  if($sameBusinessAddress>0)
			  {
				 $matchCriteria.='Business Address, ';
			  }

            $merchant_match_criteria=substr($matchCriteria, 0, strlen($matchCriteria)-2);
			
			$subject="Swapen Registration :: Merchant information matched";
			$message="A new member registered as a merchant.".$merchant_match_criteria ." matched in database with another merchant registered before.";
			$headers = "From: ".$firstName."<".$email."> \r\n";
			$headers .= 'MIME-Version: 1.0' . "\r\n";
			$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
			mail("support@swapen.com",$subject, $message, $headers);
			
		 	$sqlInsTmpUsr="INSERT INTO tbl_temp_user SET  user_id='',
  					                                      business_name='".sanitize($businessName)."',
														  physicalLocation='".sanitize($physicalLocation)."',
														  bus_id='".$btype."',
														  businessDescription='".$businessDescription."',
														  other_business_type='".$other_business_type."',
														  address_line_1='".sanitize($address1)."',
														  city='".$city."',
														  state='".$state."',
														  country='".$country."',
														  zip='".$zip."',
														  phone_number_1='".$phoneNo1."',
														  email='".$email."',
														  first_name='".sanitize($firstName)."',
														  last_name='".sanitize($lastName)."',
														  phone_number_2='".$phoneNo2."',
														  businessEmail='".$businessEmail."',
														  driverLicence='".$driverLicence."',
														  username='".sanitize($userName)."',
														  password='".$password."',
														  secret_question=".$secretQuestion.",
														  secret_answer='".sanitize($secretAnswer)."',
														  dob='".$dob."',
														  user_type=3,
														  confirmation_code='".$confirmCode."',
														  status=1,
														  created_date='".$currentDate."'";
					
			$rstInsTmpUsr = mysql_query($sqlInsTmpUsr) or die(mysql_error());
			$insertedId=mysql_insert_id();
			$user_type=="3";
			

	
			if($insertedId!='' && $insertedId>0)
			{
//	$user_type="3";
//	//echo "hi";		
//	if($user_type=="3" || $user_type=="5")
//	{
//	 
//	 $sql="select count(*) as cnt from tbl_users where status=4 AND (user_type='3' OR user_type='5') AND (business_name like '%".$businessName."%' OR address_line_1 LIKE '%".$address1."%' OR email='".$email."' OR first_name like '%".$firstName."%' OR last_name like '%".$lastName."%'  OR dob='".$dob."')";
//	 $rs=mysql_query($sql) or die(mysql_error());
//	 $row=mysql_fetch_array($rs);
//	 $cnt=$row['cnt'];
//	 
//	
//	if($cnt>0)
//	{
//		  $msg1="<table width='100%' border='0'>
//	      <tr>
//		<td width='71%' ><p><b>Hi Support team, </b> </p>
//		<p>Following user's registration info is matching to user which is closed by swapen Admin.</p></td>
//	      </tr>
//	      <tr>
//		<td width='100%' >
//		    <b>Username:</b>".$userName."<br/>
//		    <b>Email:</b>".$email."<br/>
//		    <b>First name:</b>".$firstName."<br/>
//		    <b>Last name:</b>".$lastName."<br/>
//		</td>
//	      </tr>
//	    </table>";
//	    $email1="swapen@iceincorp.com,support@swapen.com,vikas@adroitcoders.com";
//	    $mail = new PHPMailer(); // defaults to using php "mail()"
//		      $mail->MsgHTML($msg1);
//		      $mail->From       = "mail@swapen.com";
//		      //$mail->From       = "vikas@adroitcoders.com";
//		      $mail->FromName   = "Swapen.com";
//		      $mail->Subject    = "Merchant/Whole seller Account info. matching to closed user";
//		      $mail->AddAddress($email1);
//		      $mail->Send();
//	}
//      }
				
				
				$msg="<table width='100%' border='0' style='font-family:Verdana, Arial, Helvetica, sans-serif;font-size:12px; line-height:25px'>
				  <tr>
				    <td width='18%' height='41'><table width='100%' border='0'>
				      <tr>
					<td width='19%' height='68'><img src='".$base_url."images/logo.png' width='208' height='83'></td>
					<td width='81%'>Swapen sent this message to <b>".$firstName." ".$lastName."  ( ".$userName." )</b> <br>
				Your registered name is included to show this message originated from Swapen. </td>
				      </tr>
				    </table></td>
				  </tr>
				  <tr>
				    <td height='32' colspan='2' style='font-family:Verdana, Arial, Helvetica, sans-serif;font-size:13px;color:#FFFFFF;background-color:#0FB6FA;'><b>&nbsp;&nbsp;Complete your Swapen registration</b></td>
				  </tr>
				  <tr>
				    <td>
				      <table width='100%' border='0'>
					<tr>
					  <td width='71%' height='124'><p><b>Hi ".$firstName." ".$lastName." </b>, </p>
					  <p>Just click 'Activate Now' to complete your registration. That's all there is to it. After that, you are ready to start using Swapen.com</p></td>
					  <td width='29%' style='text-align:center'><b>This is the last step, we promise!</b><a href='".$base_url."index.php?confirm&cnc=".$confirmCode."&usn=".$userName."' target='_blank' style='text-decoration:none; color:#FFFFFF'><img src='".$base_url."images/activate_now.gif' width='138' height='43'></a></td>
					</tr>
				      </table>
				    </td>
				  </tr>
				  <tr>
				    <td><table width='100%' border='0'>
				      <tr>
					<td height='28' style='background-color:#F3F3F3'><b>If the above link does not work:</b></td>
				      </tr>
				      <tr>
					<td height='80'>Type in or copy and paste this link into your Web browser: <br>
					  <a href='".$base_url."index.php?confirm&cnc=".$confirmCode."&usn=".$userName."' target='_blank'>".$base_url."index.php?confirm&cnc=".$confirmCode."&usn=".$userName."</a><br></td>
				      </tr>
				    </table></td>
				  </tr>
				</table>";
				$mail = new PHPMailer(); // defaults to using php "mail()"
				$mail->MsgHTML($msg);
				$mail->From       = "registration@swapen.com";
				$mail->FromName   = "Swapen Activation";
				$mail->Subject    = "Complete your Swapen Registration--last step";
				$mail->AltBody    = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test
				$mail->AddAddress($email);
				$mail->Send();
			  $msg="<font color='#005B00'>successfully registered, Check your email for confirmation.</font>";
			}
			else
			$msg="<font color='#FF0000'>Problem in registration, Try again.</font>";
	}
	else
	{
	
		 	$sqlInsTmpUsr="INSERT INTO tbl_temp_user SET  
  					business_name='".sanitize($businessName)."',
					physicalLocation='".sanitize($physicalLocation)."',
					bus_id='".$btype."',
					businessDescription='".$businessDescription."',
					other_business_type='".$other_business_type."',
					address_line_1='".sanitize($address1)."',
					city='".$city."',
					state='".$state."',
					country='".$country."',
					zip='".$zip."',
					phone_number_1='".$phoneNo1."',
					email='".$email."',
					first_name='".sanitize($firstName)."',
					last_name='".sanitize($lastName)."',
					phone_number_2='".$phoneNo2."',
					businessEmail='".$businessEmail."',
					driverLicence='".$driverLicence."',
					username='".sanitize($userName)."',
					password='".$password."',
					secret_question=".$secretQuestion.",
					secret_answer='".sanitize($secretAnswer)."',
					dob='".$dob."',
					user_type=3,
					confirmation_code='".$confirmCode."',
					status=4,
					created_date='".$currentDate."'";
			$rstInsTmpUsr = mysql_query($sqlInsTmpUsr) or die(mysql_error());
			
	 $subject="Your New Account is Inactive";
	 $sqlEmail2="select * from tbl_emails where email_type='Register in closed account'";
	 $resEmail2=mysql_query($sqlEmail2);
	 $rowEmail2=mysql_fetch_array($resEmail2);
	 $message=str_replace('%fname%',$firstName,str_replace('%lname%',$lastName,$rowEmail2['email_body']));
	 $headers = "From: Swapen.com<mail@swapen.com> \r\n";
	 $headers .= 'MIME-Version: 1.0' . "\r\n";
	 $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
	 mail($email,$subject, $message, $headers);
	 
	 $subject2="New member has registered with old user account info";
	 $sqlEmail3="select * from tbl_emails where email_type='Register in closed account for admin'";
	 $resEmail3=mysql_query($sqlEmail3);
	 $rowEmail3=mysql_fetch_array($resEmail3);
	 $fullname=$firstName." ".$lastName;
	 $message2=str_replace('%username%',$userName,$rowEmail3['email_body']);
	 $headers2 = "From: ".$fullname."<".$email."> \r\n";
	 $headers2 .= 'MIME-Version: 1.0' . "\r\n";
	 $headers2 .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
	 mail("support@swapen.com",$subject2, $message2, $headers2);
	//$msg="<font color='#FF0000'>Same username already exist, Choose any other username.</font>";
	}
}
?>

<script src="<?php echo $base_url?>js/jquery-1.4.4.js" type="text/javascript"></script>
<script src="<?php echo $base_url?>js/jquery.custom_radio_checkbox.js" type="text/javascript"></script>
<script language="javascript" type="text/javascript">
$(document).ready(function(){
	$(".radio").dgStyle();
	$(".checkbox").dgStyle();
});
</script>
<div id='panel'>
<form name="frmRegisterMerchant" id="frmRegisterMerchant" method="post" action="index.php?registerMerchant" onsubmit="return validateRegisterMerchant()">
<input type="hidden" name="registerMerchantKey" id="registerMerchantKey" />
<table width="100%" border="0" cellpadding="0" cellspacing="0">
	<tr>
	<td>
	<div class="releftbox_out">
	<div class="releftbox_top">&nbsp;</div>
	<div class="releftbox_repeat">
	<table width="100%" border="0" cellpadding="0" cellspacing="0">
	  <tr>
		<td align="center"><img src="<?php echo $base_url?>images/register_images/register_merchantac.png" align="absmiddle" /></td>
	  </tr>
	  <tr>
		<td align="center" style="padding:10px 0px 10px 0px;">Already registered or want to make changes to your account? <a href="index.php?signin" class="bluelink">Sign in.</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#" class="bluelink">FAQ</a></td>
	  </tr>
	  <tr>
		<td>
			<div id="messageAreaTop" style="margin:10px 0px 10px 20px; float:left;"><?php if(isset($msg)) echo "<b>".$msg."</b>"; ?></div>
			
			<div class="blue_box">
				<div class="bluebar_left"></div>
				<div class="bluebar_center"><span>Tell us about your business-(required)</span></div>
				<div class="bluebar_right"></div>
			</div>
			
			<div class="blue_box">
				<div class="form_field_box">
					<label for="businessName" id="lblBusinessName">Business Name:</label>
					<span>
					
					<input type="text" name="businessName" id="businessName" value="<?php echo $_REQUEST['businessName']?>" class="inputbg" style="width:150px;" />
					
					</span>
				</div>
				<div class="form_field_box">
					<label for="physicalLocation" id="lblphysicalLocation">Physical Location Name:</label>
					<span>
					
					<input type="text" name="physicalLocation" id="physicalLocation" value="<?php echo $_REQUEST['physicalLocation']?>" class="inputbg" style="width:150px;" />
					
					</span>
				</div>
			</div>
			<div class="blue_box">
				<div class="form_field_box">
					<label for="btype" id="lblBusinessType">Business Type:</label>
					<span>
						<select name="btype" id="btype"  style="width:185px; height:28px;" class="inputbg" onchange="business_other(this.value);">
							<option value="">Select Business Type...</option> 
							<?php			   
							$sqlSelCountry="SELECT * FROM tbl_businesstype ORDER BY business_type";
							$rstSelCountry=mysql_query($sqlSelCountry);
							while($rowSelCountry=mysql_fetch_array($rstSelCountry))
							{
								$bus_id=$rowSelCountry['bus_id'];
								$business_type=$rowSelCountry['business_type'];
								?>
							<option value="<?php echo $bus_id?>"><?php echo $business_type?></option>
							<?php
							}
							?>
						</select>
						<script>$('#btype').val(<?php echo $_REQUEST['btype'];?>);</script>
					</span>
				</div>
				<div class="form_field_box">
					<label for="businessDescription" id="lblbusinessDescription">Business Description:</label>
					<span>
						<select name="businessDescription" id="businessDescription" style="width:120px; height:28px;" class="inputbg">
							<option value="retail">Retail</option>
							<option value="manufacture">Manufacture</option>
							<option value="services">Services</option>
						</select>
						<script>$('#businessDescription').val(<?php echo $_REQUEST['businessDescription'];?>);</script>
					</span>
				</div>
			</div>
			<div class="blue_box" id="other_business" style="display:none">
				<div class="form_field_box_full">
					<label for="other_business_type" id="lblother_business_type">Please Specify:</label>
					<span>
					
					<input type="text" name="other_business_type" id="other_business_type" value="<?php echo $_REQUEST['other_business_type']?>" class="inputbg" />
					
					</span>
				</div>
			</div>

			<div class="blue_box">
				<div class="form_field_box_full">
					<label for="address1" id="lblAddress1">Business Address:</label>
					<span>
					
					<input type="text" name="address1" id="address1" value="<?php echo $_REQUEST['address1']?>" class="inputbg" />
					
					</span>
				</div>
			</div>
			<div class="blue_box">
				<div class="form_field_box">
					<label for="country" id="lblCountry">Country:</label>
					<span>
						<select name="country" id="country" onChange="javascript:funSelectState(this.value,'selectedState','1')" style="width:145px; height:28px;" class="inputbg">
							<option value="">Select country...</option> 
							<?php			   
							$sqlSelCountry="SELECT * FROM tbl_country where code='US'";
							$rstSelCountry=mysql_query($sqlSelCountry);
							while($rowSelCountry=mysql_fetch_array($rstSelCountry))
							{
								$cty_id=$rowSelCountry['country_id'];
								$cty_name=$rowSelCountry['country_name'];
								echo "<option value='$cty_id' selected='selected'>$cty_name</option>";
							}
							?>
						</select>
					</span>
				</div>
				<div class="form_field_box">
					<label for="state "id="lblState">State:</label>
					<span id="selectedState">
						<select name="state" id="state" style="width:145px; height:28px;" class="inputbg">
							<option value="">Select state...</option>
							<?php
							if($_REQUEST['country']!='')
							{
								$qry = mysql_query("select stateid , statename,country_id from tbl_state where country_id='".$_REQUEST['country']."'") or die(mysql_error());
								$cnt_qry =  mysql_num_rows($qry);
								if($cnt_qry > 0)
								{
									while($row = mysql_fetch_array($qry))
									{
										if($_REQUEST['state']==$row['stateid'])
										{
									?>
										<option value="<?php echo $row['stateid']?>" selected="selected"><?php echo $row['statename']?></option>
									<?php
										}
										else {
											?>
										<option value="<?php echo $row['stateid']?>"><?php echo $row['statename']?></option>
										<?php
										}
									}
								}
								
							}
							?>	
						</select>
						<script>$('#state').val(<?php echo $_REQUEST['state'];?>);</script>
					</span>
				</div>
			</div>
			<div class="blue_box">
				<div class="form_field_box">
					<label for="city" id="lblCity">City:</label>
					<span id="selectedCity">
						<select name="city" id="city" style="width:145px; height:28px;" class="inputbg">
							<option value="">Select city...</option>
							<?php
							if($_REQUEST['state']!='')
							{
								$qry = mysql_query("select cityid , cityname,stateid from tbl_city where stateid='".$_REQUEST['state']."'") or die(mysql_error());
								$cnt_qry =  mysql_num_rows($qry);
								if($cnt_qry > 0)
								{
									while($row = mysql_fetch_array($qry))
									{
										if($_REQUEST['city']==$row['cityid'])
										{
										?>
											<option value="<?php echo $row['cityid']?>" selected="selected"><?php echo $row['cityname']?></option>
										<?php
										}
										else
										{
											?>
											<option value="<?php echo $row['cityid']?>"><?php echo $row['cityname']?></option>
											<?php
										}
									}
								}
							}
							?>
						</select>
					</span>
				</div>
				<div class="form_field_box">
					<label for="zip" id="lblZip">Zip Code:</label>
					<span>
					
					<input type="text" name="zip" id="zip"  class="inputbg" value="<?php echo $_REQUEST['zip']?>"  style="width:110px;"/>
					
					</span>
				</div>
			</div>
			<div class="blue_box">
				<div class="form_field_box_full">
					<label for="phoneNumber1" id="lblPhoneNumberPrimary">Telephone:</label>
					<span>
						
						<input type="text" name="phoneNumber1" id="phoneNumber1" value="<?php echo $_REQUEST['phoneNumber1']?>" maxlength="4" style="width:20px;" class="inputbg" /><font style="padding:10px 0px 0px 0px;"> - </font>
						
						<input type="text" name="phoneNumber2" id="phoneNumber2" value="<?php echo $_REQUEST['phoneNumber2']?>" maxlength="4" style="width:20px;"  class="inputbg" /><font style="padding:10px 0px 0px 0px;"> - </font>
						<input type="text" name="phoneNumber3" id="phoneNumber3" value="<?php echo $_REQUEST['phoneNumber3']?>" maxlength="6"  style="width:20px;"  class="inputbg" /> <font style="padding:10px 0px 0px 0px;">Ext :</font>
						<input type="text" name="extension1" id="extension1" value="<?php echo $_REQUEST['extension1']?>" maxlength="20"  style="width:30px;"  class="inputbg" />
					</span>
				</div>	
			</div>
			<div class="blue_box">
				<div class="form_field_box">
					<label for="email" id="lblEmail">Email:</label>
					<span>
					
					<input type="text" name="email" id="email" value="<?php echo $_REQUEST['email']?>"  class="inputbg" style="width:150px;" />
					
					</span>
				</div>
				<div class="form_field_box">
					<label for="emailAgain" id="lblEmailAgain">Re-enter email:</label>
					<span>
						
						<input type="text" name="emailAgain" id="emailAgain" value="<?php echo $_REQUEST['emailAgain']?>"  class="inputbg" style="width:150px;" />
						
						
						
						<input type="hidden" name="utype" id="utype" value="3" class="inputbg" />
						
					</span>
				</div>
			</div>
				
			
			
			<div class="blue_box">
				<div class="bluebar_left"></div>
				<div class="bluebar_center"><span>Business Contact Information-(required)</span></div>
				<div class="bluebar_right"></div>
			</div>
			<div class="blue_box" style="text-align:center;">
				We verify every business for authenticity. You will be contacted by our Swapen Team for verification.
			</div>
			<div class="blue_box">
				<div class="form_field_box">
					<label for="firstName" id="lblFirstName">First Name:</label>
					<span>
					
					<input type="text" name="firstName" id="firstName" value="<?php echo $_REQUEST['firstName']?>"  class="inputbg" style="width:110px;" />
					
					</span>
				</div>
				<div class="form_field_box">
					<label for="lastName" id="lblLastName">Last Name:</label>
					<span>
					
					<input type="text" name="lastName" id="lastName" value="<?php echo $_REQUEST['lastName']?>" class="inputbg" style="width:110px;" />
					
					</span>
				</div>
			</div>
			<div id="samename" style="display: none; color: #FF0000; float: left; font-weight: bold; text-align: center; width: 600px;">&nbsp;&nbsp;First Name and Last Name cannot be the same. </div>
			<div class="blue_box">
				<div class="form_field_box_full">
					<label for="phoneNumber4" id="lblPhoneNumberSecondary">Telephone:</label>
					<span>
						
						<input type="text" name="phoneNumber4" id="phoneNumber4" value="<?php echo $_REQUEST['phoneNumber4']?>" maxlength="4" style="width:20px;"  class="inputbg" /><font style=" padding:10px 0px 0px 0px;"> - </font>
						
						<input type="text" name="phoneNumber5" id="phoneNumber5" value="<?php echo $_REQUEST['phoneNumber5']?>" maxlength="4" style="width:20px;"  class="inputbg" /><font style="padding:10px 0px 0px 0px;"> - </font>
						
						<input type="text" name="phoneNumber6" id="phoneNumber6" value="<?php echo $_REQUEST['phoneNumber6']?>" maxlength="6"  style="width:20px;"  class="inputbg" /><font style="padding:10px 0px 0px 0px;"> Ext : </font>
						
						<input type="text" name="extension2" id="extension2" maxlength="20" value="<?php echo $_REQUEST['extension2']?>"  style="width:30px;"  class="inputbg" />
					</span>
				</div>	
			</div>
			<div class="blue_box">
				<div class="form_field_box">
					<label for="businessEmail" id="lblbusinessEmail">Email:</label>
					<span>
					
					<input type="text" name="businessEmail" id="businessEmail" value="<?php echo $_REQUEST['businessEmail']?>" class="inputbg" style="width:150px;" />
					
					</span>
				</div>
				<div class="form_field_box">
					<label for="businessEmailAgain" id="lblbusinessEmailAgain">Re-enter email:</label>
					<span>
						
						<input type="text" name="businessEmailAgain" id="businessEmailAgain" value="<?php echo $_REQUEST['businessEmailAgain']?>"  class="inputbg" style="width:150px;" />
						
					</span>
				</div>
			</div>
			<div class="blue_box">
				<div class="form_field_box">
					<label for="driverLicence" id="lbldriverLicence">Driver Licence#:</label>
					<span>
					
					<input type="text" name="driverLicence" id="driverLicence" value="<?php echo $_REQUEST['driverLicence']?>" class="inputbg" style="width:110px;" />
					
					</span>
				</div>
				<div class="form_field_box">
					<a href="javascript:void(0);" id="bargain_price_more_info" onclick="show_more_info(1)">why do you need my DL#?</a>
				</div>
				<div style=" display: none; width: 400px; font-weight:bold; padding:10px; background-color:#cccccc;" class="user_popup" id="more_info">
					<span style="float:left; width:100%; text-align:right; margin-bottom:5px;"><label style="cursor:pointer;" onclick="$('#more_info').fadeOut('slow');">x</label></span>
					<span style="float:left; width:100%; margin-bottom:10px;" id="desc_info_n"></span>
				</div>
			</div>
			
			<div class="blue_box">
				<div class="bluebar_left"></div>
				<div class="bluebar_center"><span>Choose your username and password-(required)</span></div>
				<div class="bluebar_right"></div>
			</div>
			<div class="blue_box">
				<div class="form_field_box_full">
					<label for="userName" id="lblUserName">Create Username:</label>
					<span>
					
					<input type="text" name="userName" id="userName" value="<?php echo $_REQUEST['userName']?>" style="width:200px;" class="inputbg" />
					
					</span>
				</div>
				
			</div>
			<div class="blue_box">
				<div class="form_field_box_full">
					<label for="password" id="lblPassword">Create Password:</label>
					<span>
					
					<input type="password" name="password" id="password"  style="width:200px;" class="inputbg" />
					
					</span>
				</div>
				
			</div>
			<div id="errmsg" style="color:red"></div>
			<div class="blue_box">
				<div class="form_field_box_full">
					<label for="confirmPassword" id="lblConfirmPassword">Re-enter Password:</label>
					<span>
					
					<input type="password" name="confirmPassword" id="confirmPassword"  style="width:200px;" class="inputbg" />
					
					</span>
				</div>
				
			</div>
			<div class="blue_box">
				<div class="form_field_box_full">
					<label for="secretQuestion" id="lblSecretQuestion">Pick a secret question:</label>
					<span>
						<select name="secretQuestion" id="secretQuestion" style="width:300px; height:28px;" class="inputbg">
							<option value="">Select a secret question</option>
							<?php
							$sqlSelQuestion = "select * from tbl_questions";
							$rstSelQuestion = mysql_query($sqlSelQuestion) or die(mysql_error());
							while($rowSelQuestion = mysql_fetch_array($rstSelQuestion))
							{ ?>
							<option value="<?php echo $rowSelQuestion['question_id'] ?>"><?php echo $rowSelQuestion['question'] ?></option>
							<?php } ?>
						</select>
						<script>$('#secretQuestion').val(<?php echo $_REQUEST['secretQuestion'];?>);</script>
					</span>
				</div>
				
			</div>
			<div class="blue_box">
				<div class="form_field_box_full">
					<label for="secretAnswer" id="lblSecretAnswer">Your seceret answer:</label>
					<span>
					
					<input type="text" name="secretAnswer" id="secretAnswer" value="<?php echo $_REQUEST['secretAnswer']?>" class="inputbg" style="width:300px;" />
					
					</span>
				</div>
			</div>
			<div class="blue_box">
				<div class="form_field_box_full">
					<label for="dMonth" id="lblDOB">Date of birth:</label>
					<span>
						
						<select name="dMonth" id="dMonth" style="width:100px; height:28px;" class="inputbg">
							<option value="">--Month--</option>
							<option value="01">January</option>
							<option value="02">February</option>
							<option value="03">March</option>
							<option value="04">April</option>
							<option value="05">May</option>
							<option value="06">June</option>
							<option value="07">July</option>
							<option value="08">August</option>
							<option value="09">September</option>
							<option value="10">October</option>
							<option value="11">November</option>
							<option value="12">December</option>
						</select>&nbsp;&nbsp;
						<script>$('#dMonth').val('<?php echo $_REQUEST['dMonth'];?>');</script>
						<select name="dDay" id="dDay" style="width:80px; height:28px;" class="inputbg">
							<option value="">--Day--</option>
							<?php
							for($i=1;$i<=31;$i++)
							{
								if($i<=9)
								$d = '0'.$i;
								else
								$d = $i;
								?>
								<option value="<?php echo $d;?>"><?php echo $d;?></option>
								<?php
							}
							?>
						</select>&nbsp;&nbsp;
						<script>$('#dDay').val(<?php echo $_REQUEST['dDay'];?>);</script>
						
						<input type="dYear" name="dYear" id="dYear" value="<?php echo $_REQUEST['dYear']?>" onclick="this.value=''" style="width:40px;" maxlength="4" class="inputbg" />
						
						<br />
						<span class="boldGreyNotes" id="lblAgeNote" style="margin:5px 0px 10px 0px;">You must be at least 18 years old to use Swapen.</span>
					</span>
				</div>
			</div>
			<div class="blue_box">
				<div class="form_field_box_full" style="margin:10px 0px 10px 0px;">
					<label for="securityCode" id="lblSecurityCode">Prove you're human:</label>
					<span>
						<img id="siimage" align="left" style="padding-right: 5px; border: 0" src="securimage_show.php?sid=<?php echo md5(uniqid(time())); ?>" />
						<a tabindex="-1" style="border-style: none" href="#" title="Refresh Image" onclick="document.getElementById('siimage').src = 'securimage_show.php?sid=' + Math.random(); return false">
						<img src="images/reload.png" alt="Reload Image" border="0" onclick="this.blur()" align="bottom" /></a><br />
						
						<input type="text" name="securityCode" id="securityCode" style="width:200px;" class="inputbg" />
						
					</span>
				</div>
			</div>
			<div class="blue_box">
				&nbsp;
			</div>
			<div class="blue_box">
				<div class="form_field_box_full">
					<div class="checkbox"><input name="accept" id="accept" type="checkbox" /> </div> &nbsp;&nbsp;
					<label style="text-align:left;">I agree that:</label>
					<div id="lblAgreement" style="display:none; color:#FF0000; font-weight:bold">Acceptance of  agreement is must to register. </div>
				</div>
				<br /><br /><br />
				<ul>
					<li>I accept the <a href="" tabindex="1">User Agreement</a> and <a href="index.php?policy" target="_blank">Privacy Policy</a>.</li>
					<li>I may receive communications from swapen.</li>
					<li>I'm at least 18 years old.</li>
				</ul>
			</div>
			<div class="blue_box" style="text-align:center;">
				<input type="submit" name="submit" id="submit" value="REGISTER" class="sbmt_btn" />
			</div>
			<div id="messageAreaBottom" style="margin:10px 0px 10px 20px; float:left;"></div>
			
		</td>
	  </tr>
	  
  	</table>
	</div>
	<div class="releftbox_bot">&nbsp;</div>
	</div>
	
	<div class="rergtbox_out">
	<div class="rergtbox_top">&nbsp;</div>
	<div class="rergtbox_repeat">
		<ul class="register">
			<li>Verified Local Pick-Up
				<div class="bluebigarrow">&nbsp;</div>
			</li>
			<li>Custom Wanted Items List
				<div class="bluebigarrow">&nbsp;</div>
			</li>
			<li>Sell Products FOR Other Users
				<div class="bluebigarrow">&nbsp;</div>
			</li>
			<li>Have YOUR Products Sold for YOU
				<div class="bluebigarrow">&nbsp;</div>
			</li>
			<li>All Our Merchant are <font style="color:#24299B;">Verified</font>
				<div class="bluebigarrow">&nbsp;</div>
			</li>
			<li>Referral Commission Program
				<div class="bluebigarrow">&nbsp;</div>
			</li>
			<li>AND MUCH MUCH MORE<br />
				AND ITS ALL FREE!
				<div class="bluebigarrow">&nbsp;</div>
			</li>
		</ul>
		
		<div class="fulldiv">
			<div class="quoteimg">&nbsp;</div>
		</div>
		<div class="fulldiv">
			<div class="quote">
			I've owned my physical store for more than a decade selling 
			clothing for all ages and have done pretty well. When I found out 
			Swapen.com caters to sellers like me I decided to give it a try 
			and my sales rose 20%. Thank you Swapen.com.
			<div style="float:right; text-align:right; margin:10px 0px 0px 0px;">Jack 56 Utah</div>
			</div>
		</div>
		
		<div class="fulldiv">
			<div class="quoteimg">&nbsp;</div>
		</div>
		<div class="fulldiv">
			<div class="quote">
			I saw Swapen.com advertise that what the merchant receives when they 
			sign up and I was very sceptucle at first, but I went ahead 
			and signed up. I got a free store, no listing fees, optional local pickup  
			for customers, and best all of they have sellers who picked up  
			my product to sell on behalf of myself.<br/>
			<div style="float:right; text-align:right; margin:10px 0px 0px 0px;">James 30 California</div>
			</div>
		</div>
		
		<div class="fulldiv">
			<div class="quoteimg">&nbsp;</div>
		</div>
		<div class="fulldiv">
			<div class="quote">
			I started my business 5 years ago selling tires and when 
			the economic downturn hit I was on the verge of going bankcrupt.
			Swapen.com saved my business by allowing me to over tires at 
			a discount online for either local pick which could include 
			installtion or shiptment. Thank you so much Swapen.com <br>
			<div style="float:right; text-align:right; margin:10px 0px 0px 0px;">Dan 45 Arizona</div>
			</div>
		</div>
		
		<div class="fulldiv">
			<div class="lock_text">Your privacy<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;is important to us...</div>
		</div>
		
		<div class="fulldiv">
			<div class="lockimg">&nbsp;</div>
		</div>
		
		<div class="fulldiv">
			<div class="privacy_txt">
			Swapen does not rent or sell your information
			to third parties without your consent. To learn 
			more, read our <a href="#" class="bluelink">privacy policy</a>
			</div>
		</div>	
		
	</div>
	<div class="rergtbox_bot">&nbsp;</div>
	</div>
	</td>
  	</tr>
</table>

</form>
</div>
<?php
    if(empty($_REQUEST['state']))
    {
?>
   <script>
      $(document).ready(function() {
	funSelectState('213','selectedState','1');
       });
   </script>
<?php
    }
?>
<script>
      function show_more_info(a)
      {
		var pos = $('#bargain_price_more_info').position();
		//alert(pos);
		var nleft = parseInt(pos.left);
		var ntop = parseInt(pos.top)+15;
		$('#more_info').css({'left': nleft, 'top':ntop});
		$('#desc_info_n').html('Driver License is needed for verification purposes only. This is to make sure that you are associated with the business.');
		$('#more_info').fadeIn('slow');
		//$('#more_info').show();
	
      }
	  
	  function business_other(bus)
	  {
	    if(bus==59)
		{
		  document.getElementById('other_business').style.display='';
		}
		else
		{
		  document.getElementById('other_business').style.display='none';
		}
	  }
   </script>
